package com.demo.pattern.singleton;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

/**
 * @author linchong
 * @version 1.0
 * @Date: 2022-05-22 15:00
 * @Description: EnumStarvingSingletom$
 */
public class EnumStarvingSingleton {

	private EnumStarvingSingleton(){};

	public static EnumStarvingSingleton getInstance(){
		return ContainerHolder.HOLDER.instance;
	}

	private enum ContainerHolder{
		HOLDER;
		private EnumStarvingSingleton instance;
		ContainerHolder(){
			instance = new EnumStarvingSingleton();
		}
	}

/*	public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
		Class clazz = ContainerHolder.class;
		//Constructor constructor = clazz.getDeclaredConstructor();
		Constructor constructor = clazz.getDeclaredConstructor(String.class,int.class);
		constructor.setAccessible(true);
		System.out.println(EnumStarvingSingleton.getInstance());
		System.out.println(constructor.newInstance());
	}*/

}
